<template>
    <div class="header">
      <!-- 将卡片放入 header 内，并使用 v-show 控制显示 -->
      <div class="card" v-for="(card, index) in cards" :key="index" v-show="activeCard === index">
        <div class="card-header">{{ card.title }}
          <span v-if="activeCard === 1">&#128065;</span> <!-- 小眼睛图标 -->
        </div>
        <div class="main-content">
          <p class="rate">{{ card.content }}</p>
        </div>
      </div>
  
      <!-- 根据卡片索引显示不同的按钮或图标 -->
      <div v-if="activeCard === 0">
        <button @click="changeCard(1)">点击登录</button>
      </div>
      <div v-else-if="activeCard === 1">
        <div class="icon-item" @click="changeCard(2)" title="切换到昨日收益（元）">
          <font-awesome-icon :icon="['fas', 'arrow-right']" />
        </div>
      </div>
      <div v-else-if="activeCard === 2">
        <div class="icon-item" @click="changeCard(3)" title="切换到昨日收益（元）">
          <font-awesome-icon :icon="['fas', 'arrow-right']" />
        </div>
      </div>
      <div v-else-if="activeCard === 3">
        <div class="icon-item" @click="changeCard(0)" title="切换到登录查看资产情况">
          <font-awesome-icon :icon="['fas', 'arrow-left']" />
        </div>
      </div>
    </div>
  </template>
  
  <script>
  import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
  
  export default {
    components: {
      FontAwesomeIcon,
    },
    props: {
      activeCard: Number,
      cards: Array,
    },
    methods: {
      changeCard(index) {
        this.$emit('change-card', index);
      },
    },
  };
  </script>
  
  <style scoped>
  .header {
    width: 100%;
    height: 240px;
    background-image: url('./assets_page3/dingbu.svg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }
  
  .card-header {
    font-weight: bold;
    margin-bottom: 10px;
    position: relative;
    background-color: transparent;
  }
  
  .card-header span {
    margin-left: 10px;
    font-size: 1.2em;
  }
  
  .icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    margin: 10px;
  }
  </style>